Master Page throws "The webpage cannot be found"

Hi guys! I have small problem with Master Page. I have created Web Template and Master Page. When I create new site collection and I try access to it (http://win2008r2/sites/Test), it throws me error that: "The webpage cannot be found".

However, when I check MasterPage gallery: http://win2008r2/sites/Test/_catalogs/masterpage/Forms/AllItems.aspx

I can find my Demo.master . When I check Site Collection Features, I can see that my Master Page feature is active.

I have set Web Template scope to farm and I have set Master Page scope to site.

I checked the logs and this was only thing what I found: Failure when fetching document. 0x80070002

I try to solve problem using google and I tried different guides but no I cannot get it work.

Can anyone please help me?

Here is Element.xml:

  <Module Name="MyMasterPage" List="116" Url="_catalogs/masterpage">
    <File Path="MyMasterPage\Demo.master" Url="Demo.master" Type="GhostableInLibrary">
    </File>
  </Module>

Here is event receiver:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPWeb _web = ((SPSite)properties.Feature.Parent).RootWeb)
                {
                    Uri _siteMaster = new Uri(string.Format("{0}/_catalogs/masterpage/Demo.master", _web.Url));
                    _web.MasterUrl = _siteMaster.AbsolutePath;
                    _web.CustomMasterUrl = _siteMaster.AbsolutePath;
                    _web.Update();
                }
            });
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite curSite = (SPSite)properties.Feature.Parent;
            SPWeb curWeb = curSite.RootWeb;
            Uri masterUri = new Uri(curWeb.Url + "/_catalogs/masterpage/v4.master");
            curWeb.MasterUrl = masterUri.AbsolutePath;
            curWeb.CustomMasterUrl = masterUri.AbsolutePath;
            curWeb.Update();
        }



  • Edited by Lindsey24 Wednesday, January 08, 2014 7:54 AM Added error code
January 8th, 2014 10:43am

ONet.xml file, I add my Master Page:

<SiteFeatures>
<Feature ID="034a0d23-039e-480d-8aa7-1dee8d60e53f"/>
</SiteFeatures>


Free Windows Admin Tool Kit Click here and download it now
January 8th, 2014 2:21pm

I have struggled for a couple of days with this problem, I have begun to feel like that this is not possible to make using SharePoint Foundation. Can anyone give any advice? Is it possible or not what I'm trying to do? I can create Master Page and get it work and I can create Web Template, however I cannot combine them because something breaks down
  • Edited by Lindsey24 Wednesday, January 08, 2014 12:23 PM Added text
January 8th, 2014 3:21pm

Hi Lindsey24,

Please change the master page feature scope to web if you want to use the custom master page to the web you created, ,make the solution to be a farm solution not sandboxed. Debug to deploy the solution again, check the result.

Check whether there are steps missing comparing with following sample:
http://mohitvash.wordpress.com/2011/07/08/custom-site-definition-with-custom-masterpage/

Thanks,

Free Windows Admin Tool Kit Click here and download it now
January 14th, 2014 3:59am

Hello Lin,

i think you are using wrong url.

the Module what you are using will deploy master page Demo.master to the masterpage gallery of Root Site collection. you can see there .. Means ..at bellow url

http://win2008r2/_catalogs/masterpage

in your module modify the url property to

/sites/Test/_catalogs/masterpage

Hope it will Help

January 14th, 2014 4:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics